<?php
if (isset($_POST['email'], $_POST['pwd']))
{
		
	$email = $_POST['email'];
	$pwd = $_POST['pwd'];
	
	include_once 'Util/includeAll.php';
	
	if (AuthUser($email, $pwd)==1)
	{	
		$rq = "SELECT\n".
			"message.id,\n".
			"message.dest_number,\n".
			"message.txt,\n".
			"message.dh\n".
			"FROM\n".
			"message\n".
			"INNER JOIN `user` ON message.id_user = `user`.id ".
			"WHERE\n".
			"`user`.email = '$email' AND\n".
			"`user`.pwd = MD5('$pwd') AND\n".
			"message.accuse = 0";
		
		$retour = executeBDD($rq);
			
		if($retour != null)
		{
			echo "<SMSs>";
			$num_rows = mysql_num_rows($retour);
			if ($num_rows != 0)
			{
				
				while($donnees = mysql_fetch_array($retour))
				{
					$id= $donnees['id'];
					$dest_num= $donnees['dest_number'];
					$txt= utf8_decode($donnees['txt']);
					$dh = strtotime($donnees['dh']);
					echo "<SMS id=\"$id\"><dest value=\"$dest_num\"/><text value=\"$txt\"/><dh value=\"$dh\"/></SMS>";
				}
				
			}
			echo "</SMSs>";
			
			//on met à jour la dernier data de MaJ du portable
			//TODO a tester
			$u =getUser(true);
			$u->phone->MaJLastActivity();
		}
		else
		{
			echo "Une erreur s'est produite :(";
		}
	}
}
else
{
	echo "Params manquants !";
}

?>